const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "自增id",
      field: "id"
    },
    pid: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "父id",
      field: "pid"
    },
    name: {
      type: DataTypes.STRING(255),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "名称",
      field: "name"
    },
    level: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "级别类型（1:一级[所有省], 2：二级[所有市], 3:三级[所有区县], 4:街道[所有街道]）",
      field: "level"
    },
    letters: {
      type: DataTypes.CHAR(3),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "城市首字母",
      field: "letters"
    },
    code: {
      type: DataTypes.CHAR(30),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "编码",
      field: "code"
    },
    lng: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.0000000000",
      primaryKey: false,
      autoIncrement: false,
      comment: "经度",
      field: "lng"
    },
    lat: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.0000000000",
      primaryKey: false,
      autoIncrement: false,
      comment: "纬度",
      field: "lat"
    },
    sort: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "排序",
      field: "sort"
    },
    is_enable: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "1",
      primaryKey: false,
      autoIncrement: false,
      comment: "是否启用（0否，1是）",
      field: "is_enable"
    },
    add_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "添加时间",
      field: "add_time"
    },
    upd_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "更新时间",
      field: "upd_time"
    }
  };
  const options = {
    tableName: "sxo_region",
    comment: "",
    indexes: [{
      name: "pid",
      unique: false,
      type: "BTREE",
      fields: ["pid"]
    }, {
      name: "is_enable",
      unique: false,
      type: "BTREE",
      fields: ["is_enable"]
    }, {
      name: "sort",
      unique: false,
      type: "BTREE",
      fields: ["sort"]
    }, {
      name: "level",
      unique: false,
      type: "BTREE",
      fields: ["level"]
    }, {
      name: "letters",
      unique: false,
      type: "BTREE",
      fields: ["letters"]
    }, {
      name: "code",
      unique: false,
      type: "BTREE",
      fields: ["code"]
    }]
  };
  const SxoRegionModel = sequelize.define("sxo_region_model", attributes, options);
  return SxoRegionModel;
};